import { Component } from 'react';
import React from 'react';
import { connect } from 'umi';

import HighPerformTable from '@/components/HighPerformTable';
import KeywordFilterSearch from '@/components/KeywordFilterSearch';
import { Button } from 'antd';
import { PlusOutlined } from '@ant-design/icons';

class TrainingCheckManager extends Component<any, any> {
  actionRef: any;

  constructor(props: any) {
    super(props);
  }

  componentDidMount() {}

  clomns: any = [
    {
      title: '班级名称',
      dataIndex: 'name',
      rules: [
        {
          required: true,
          message: '规则名称为必填项',
        },
      ],
    },
    {
      title: '学院',
      dataIndex: 'desc',
      valueType: 'textarea',
    },
    {
      title: '班主任',
      dataIndex: 'callNo',
      sorter: true,
      hideInForm: true,
      renderText: (val: string) => `${val} 万`,
    },
    {
      title: '学生',
      dataIndex: 'status',
      hideInForm: true,
      valueEnum: {
        0: { text: '关闭', status: 'Default' },
        1: { text: '运行中', status: 'Processing' },
        2: { text: '已上线', status: 'Success' },
        3: { text: '异常', status: 'Error' },
      },
    },
    {
      title: '更新时间',
      dataIndex: 'desc',
      valueType: 'textarea',
    },
  ];
  handleDataImport() {}
  handleDataExport() {}
  render() {
    return (
      <div>
        <KeywordFilterSearch
          filters={[
            {
              title: '学院',
              multiple: false,
              keywords: ['全部', '计算机学院', '轨道交通学院', '电气工程学院'],
            },
            { title: '年级', multiple: false, keywords: ['全部', '2015', '2016', '2017', '2018'] },
          ]}
        ></KeywordFilterSearch>
        <HighPerformTable<any>
          ref={(ref) => (this.actionRef = ref)}
          additionOptions={[
            {
              title: '查看',
              onClick: (record: any) => {
                this.props.history.push('/teaching/classD');
              },
            },
          ]}
          toolBarRender={() => [
            <Button type="primary" onClick={() => this.actionRef.handleModalVisible(true)}>
              <PlusOutlined /> 新增班级
            </Button>,
            <Button type="primary" onClick={() => this.handleDataImport()}>
              批量导入
            </Button>,
            <Button type="primary" onClick={() => this.handleDataExport()}>
              批量导出
            </Button>,
          ]}
          columns={this.clomns}
        />
      </div>
    );
  }
}

export default connect()(TrainingCheckManager);
